package me.codegenerator2.utils;

import java.util.ArrayList;
import java.util.List;

public class CommonStringHandleUtil {
    public static List<Integer> checkStringContainUppercase(String columnName) {
        List<Integer> result = new ArrayList<Integer>();
        for (int i = 0; i < columnName.length(); i++) {
            if (Character.isUpperCase(columnName.charAt(i))) {
                result.add(i);
            }
        }
        return result;
    }

    public static String stringArrayToStringWithComma(String[] stringArray) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < stringArray.length; i++) {
            sb.append(stringArray[i]);
            if (i != stringArray.length - 1) {
                sb.append(",");
            }
        }
        return sb.toString();
    }


    public static String stringArrayToStringWithCommaForSql(String[] stringArray) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < stringArray.length; i++) {
            sb.append("`");
            sb.append(stringArray[i]);
            sb.append("`");
            if (i != stringArray.length - 1) {
                sb.append(",");
            }
        }
        return sb.toString();
    }

}
